

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Show Topic</title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${resource(dir:'')}">Home</a></span>
            <span class="menuButton"><g:link class="list" action="list">Topic List</g:link></span>
            <span class="menuButton"><g:link class="create" action="create">New Topic</g:link></span>
        </div>
        <div class="body">
            <h1>Show Topic</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="dialog">
                <table>
                    <tbody>
                    
                        <tr class="prop">
                            <td valign="top" class="name">话题:</td>
                            
                            <td valign="top" class="value">${fieldValue(bean:topicInstance, field:'name')}</td>
                            
                        </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name">类别:</td>
                            
                            <td valign="top" class="value"><g:link controller="topicCategory" action="show" id="${topicInstance?.topicCategory?.id}">${topicInstance?.topicCategory?.encodeAsHTML()}</g:link></td>
                            
                        </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name">当前参与人数:</td>
                            
                            <td valign="top" class="value">${fieldValue(bean:topicInstance, field:'currentSpeakerNum')}</td>
                            
                        </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name">开始时间:</td>
                            
                            <td valign="top" class="value">${fieldValue(bean:topicInstance, field:'dateCreated')}</td>
                            
                        </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name">结束时间:</td>
                            
                            <td valign="top" class="value">${fieldValue(bean:topicInstance, field:'endTime')}</td>
                            
                        </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name">Description:</td>
                            
                            <td valign="top" class="value">${fieldValue(bean:topicInstance, field:'description')}</td>
                            
                        </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name">Image:</td>
                            
                            <td valign="top" class="value">
                            <g:if test="${topicInstance.image}">
                            	<img src="<g:createLink controller='topic' action='renderImage' id='${topicInstance.id}'/>" onerror="javascript:this.src='${resource(dir:'images',file:'aitaolun_logo.jpg')}'"/>
                            </g:if>
                            </td>
                            
                        </tr>
                        
                        <tr class="prop">
                        	<td valign="top" class="name">话题讨论者:</td>
                            
                            <td valign="top" class="value">
                            	<g:each in="${topicInstance.speakers()}" var="topicUser">
                            		${topicUser?.username} <br/>
                            	</g:each>
                            </td>
                            
                        </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name">Opinions:</td>
                            
                            <td  valign="top" style="text-align:left;" class="value">
                                <ul>
                                <g:each var="o" in="${topicInstance.opinions}">
                                    <li><g:link controller="opinion" action="show" id="${o.id}">${o?.encodeAsHTML()}</g:link><br/>
                                    <div>${o?.opinion.encodeAsHTML()}</div>
                                    <div><comments:render bean="${o}" /></div>
                                    </li>
                                </g:each>
                                </ul>
                            </td>
                            
                        </tr>
                    
                    </tbody>
                </table>
            </div>
            <div class="buttons">
            </div>

            <div class="buttons">
              <g:if test="${session.user == topicInstance.owner || session.user in topicInstance.speakers()}">
                <g:form controller="opinion" action="addOpinion">
                    <input type="hidden" name="topicId" value="${topicInstance?.id}" />
                    <g:textArea id="opinion" name="opinion" rows="3" style="width:99%;overflow-x:visible;overflow-y:visible;"></g:textArea><br/>
                    <span class="button"><g:actionSubmit class="edit" value="发言" action="addOpinion"/></span>
                </g:form>
              </g:if>

              <g:elseif test="${session.user in topicInstance.viewers()}">
                <input value="评论"/>
              </g:elseif>
              <g:else>
                加入发言或成为观众
              </g:else>
            </div>
        </div>
    </body>
</html>
